package com.jgdt.demo.api;
import com.jgdt.demo.AppContext;
import com.bcia.assetmange.BuildConfig;
import com.jgdt.demo.utils.NetworkHelper;
import com.librariy.net.HttpRequest;
public class JsonRequest extends HttpRequest {
    public static String REST_SERVER_BASE_URL= BuildConfig.HOST_API[1];//正式接口
    public static String REST_SERVER_BASE_H5_URL=BuildConfig.HOST_H5[1];//H5正式接口
    public JsonRequest(Method method) {
        super(method);
    }
    public JsonRequest(Method method, String formatApiURI, Object... args) {
        super(method, formatApiURI, args);
    }
    @Override
    protected void initializeDefault() {
        // 在各个项目中需要覆盖这些默认参数
        super.setBaseURI(REST_SERVER_BASE_URL);
        super.setHeader("token",AccessCtrl.getToken());
    }

    @Override
    protected void checkBeforeRequest() throws UnsupportedOperationException {
        super.checkBeforeRequest();
        if(AppContext.I!=null&&!NetworkHelper.isConnected(AppContext.I)){
            throw new UnsupportedOperationException("网络未连接");
        }
    }
}